*   HANEGRAAFF, VERGAUWEN & BEYERS (2019), "SHOULD I STAY OR SHOULD I GO? EXPLAINING VARIATION IN NON-STATE ACTOR ADVOCACY OVER TIME IN GLOBAL GOVERNANCE", GOVERNANCE
*	STATA SYNTAX FOR REPRODUCING MAIN PAPER RESULTS
*	THE DATASET INCLUDES PUBLICLY AVAILABLE INFORMATION, COMPILED AT THE UNIVERSITY OF ANTWERP
*	FOR MORE INFORMATION ON THE COLLECTED DATA, PLEASE CONTACT JAN.BEYERS@UANTWERPEN.BE

* PART 1: INSTALLATION OF THE LONGITUDINAL DATASET
* PART 2: ASSIGNING TIME-VARYING INFORMATION TO ORGANIZATIONS AND COPS
* PART 3: CONSTRUCTION OF RISK SET AND DEPENDENT VARIABLE
* PART 4: PREPARATION OF INDEPENDENT VARIABLES
* PART 5: COMPUTATION OF BASELINE HAZARD FUNCTION BY MEANS OF SPLINES
* PART 6: ANALYSIS (TABLE 2)
* PART 7: SENSITIVITY ANALYSIS (TABLE A4)

* Please note that all syntax lines referring to datafiles or local directories should link to the correct location on your local machine first (i.e. command lines "use", "cd" and "merge")
use "\...\COP dataset - analysis.dta" , clear
cd "\...\Analysis\"
* 0) Descriptives: Figure 2 of paper (Number of appearances at all COPs (not necessarily in a row))
egen Attendancy = rowtotal(COP3 COP4 COP5 COP6_1 COP6_2 COP7 COP8 COP9 COP10 COP11 COP12 COP13 COP14 COP15 COP16 COP17)
tab Attendancy
histogram Attendancy if Attendancy > 0, freq  xlabel(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15, valuelabel) addlabels

* 1) Install longitudinal dataset
* generate maximum exposure: first entry of a COP
generate COPentry = 15
replace COPentry = 14 if COP16 == 1
replace COPentry = 13 if COP15 == 1
replace COPentry = 12 if COP14 == 1
replace COPentry = 11 if COP13 == 1
replace COPentry = 10 if COP12 == 1
replace COPentry = 9 if COP11 == 1
replace COPentry = 8 if COP10 == 1
replace COPentry = 7 if COP9 == 1
replace COPentry = 6 if COP8 == 1
replace COPentry = 5 if COP7 == 1
replace COPentry = 4 if COP6_2 == 1
replace COPentry = 3 if COP6_1 == 1
replace COPentry = 2 if COP5 == 1
replace COPentry = 1 if COP4 == 1
replace COPentry = 0 if COP3 == 1
tab COPentry
generate COPexposure = 15-COPentry

* register participation to a COP (1)
generate COP3_time = .
replace COP3_time = 0 if COP3 == 1
generate COP4_time = .
replace COP4_time = 1 if COP4 == 1
generate COP5_time = .
replace COP5_time = 2 if COP5 == 1
generate COP6_1_time = .
replace COP6_1_time = 3 if COP6_1 == 1
generate COP6_2_time = .
replace COP6_2_time = 4 if COP6_2 == 1
generate COP7_time = .
replace COP7_time = 5 if COP7 == 1
generate COP8_time = .	
replace COP8_time = 6 if COP8 == 1
generate COP9_time = .
replace COP9_time = 7 if COP9 == 1
generate COP10_time = .
replace COP10_time = 8 if COP10 == 1
generate COP11_time = .
replace COP11_time = 9 if COP11 == 1
generate COP12_time = .
replace COP12_time = 10 if COP12 == 1
generate COP13_time = .
replace COP13_time = 11 if COP13== 1
generate COP14_time = .
replace COP14_time = 12 if COP14 == 1
generate COP15_time = .
replace COP15_time = 13 if COP15 == 1
generate COP16_time = .
replace COP16_time = 14 if COP16 == 1
generate COP17_time = .
replace COP17_time = 15 if COP17 == 1

* number of intervals at risk for expansion
* calculate # conferences since first entry
* sum max. exposure + 1
generate maxexporigin = COPexposure + 1
egen test = total(maxexporigin)
tab test

* expansion of data-file: transpose to a conference-period file per organization
generate periodfile_id = _n
expand maxexporigin
bysort periodfile_id: generate exposure = _n
replace exposure = exposure - 1
sort periodfile_id

* install clock time in relation to first observed COP
generate exposure2 = COPentry + exposure
* register participation to a COP in relation to clock time
generate event = 0
replace event = 1 if exposure2 == COP3_time
replace event = 1 if exposure2 == COP4_time
replace event = 1 if exposure2 == COP5_time
replace event = 1 if exposure2 == COP6_1_time
replace event = 1 if exposure2 == COP6_2_time
replace event = 1 if exposure2 == COP7_time
replace event = 1 if exposure2 == COP8_time
replace event = 1 if exposure2 == COP9_time
replace event = 1 if exposure2 == COP10_time
replace event = 1 if exposure2 == COP11_time
replace event = 1 if exposure2 == COP12_time
replace event = 1 if exposure2 == COP13_time
replace event = 1 if exposure2 == COP14_time
replace event = 1 if exposure2 == COP15_time
replace event = 1 if exposure2 == COP16_time
replace event = 1 if exposure2 == COP17_time

* 2) Assign variables to organizations and conferences
* assign years to conferences
generate year_tv = 1997 + exposure2
* COP 6.2 en 7 both in 2001
replace year_tv = 2001 if exposure2 == 5
replace year_tv = year_tv-1 if exposure2 >= 6

* merge country statistics
generate merge_ID = HEADQ*1000 if HEADQ >= 8
replace merge_ID = merge_ID+exposure2
sort merge_ID
merge merge_ID using "\...\1a  COP country statistics.dta"

* merge economy density
generate merge_eco_ID1 = 0 if isic1H == "6666"
replace merge_eco_ID1 = 100 if isic1H == "A"
replace merge_eco_ID1 = 200 if isic1H == "B"
replace merge_eco_ID1 = 300 if isic1H == "C"
replace merge_eco_ID1 = 400 if isic1H == "D"
replace merge_eco_ID1 = 500 if isic1H == "E"
replace merge_eco_ID1 = 600 if isic1H == "F"
replace merge_eco_ID1 = 700 if isic1H == "G"
replace merge_eco_ID1 = 800 if isic1H == "H"
replace merge_eco_ID1 = 900 if isic1H == "I"
replace merge_eco_ID1 = 1000 if isic1H == "J"
replace merge_eco_ID1 = 1100 if isic1H == "K"
replace merge_eco_ID1 = 1200 if isic1H == "L"
replace merge_eco_ID1 = 1300 if isic1H == "M"
replace merge_eco_ID1 = 1400 if isic1H == "N"
replace merge_eco_ID1 = 1500 if isic1H == "O"
replace merge_eco_ID1 = 1600 if isic1H == "P"
replace merge_eco_ID1 = 1700 if isic1H == "Q"
replace merge_eco_ID1 = 1800 if isic1H == "R"
replace merge_eco_ID1 = 1900 if isic1H == "S"
replace merge_eco_ID1 = merge_eco_ID1 + exposure2
drop _merge
sort merge_eco_ID1
merge merge_eco_ID1 using "\...\1b  COP economic density isic1.dta"
generate merge_eco_ID2 = 0 if isic2H == "6666"
replace merge_eco_ID2 = 100 if isic2H == "A"
replace merge_eco_ID2 = 200 if isic2H == "B"
replace merge_eco_ID2 = 300 if isic2H == "C"
replace merge_eco_ID2 = 400 if isic2H == "D"
replace merge_eco_ID2 = 500 if isic2H == "E"
replace merge_eco_ID2 = 600 if isic2H == "F"
replace merge_eco_ID2 = 700 if isic2H == "G"
replace merge_eco_ID2 = 800 if isic2H == "H"
replace merge_eco_ID2 = 900 if isic2H == "I"
replace merge_eco_ID2 = 1000 if isic2H == "J"
replace merge_eco_ID2 = 1100 if isic2H == "K"
replace merge_eco_ID2 = 1200 if isic2H == "L"
replace merge_eco_ID2 = 1300 if isic2H == "M"
replace merge_eco_ID2 = 1400 if isic2H == "N"
replace merge_eco_ID2 = 1500 if isic2H == "O"
replace merge_eco_ID2 = 1600 if isic2H == "P"
replace merge_eco_ID2 = 1700 if isic2H == "Q"
replace merge_eco_ID2 = 1800 if isic2H == "R"
replace merge_eco_ID2 = 1900 if isic2H == "S"
replace merge_eco_ID2 = merge_eco_ID2 + exposure2
drop _merge
sort merge_eco_ID2
merge merge_eco_ID2 using "\...\1b  COP economic density isic2.dta"
generate merge_eco_ID3 = 0 if isic3H == "6666"
replace merge_eco_ID3 = 100 if isic3H == "A"
replace merge_eco_ID3 = 200 if isic3H == "B"
replace merge_eco_ID3 = 300 if isic3H == "C"
replace merge_eco_ID3 = 400 if isic3H == "D"
replace merge_eco_ID3 = 500 if isic3H == "E"
replace merge_eco_ID3 = 600 if isic3H == "F"
replace merge_eco_ID3 = 700 if isic3H == "G"
replace merge_eco_ID3 = 800 if isic3H == "H"
replace merge_eco_ID3 = 900 if isic3H == "I"
replace merge_eco_ID3 = 1000 if isic3H == "J"
replace merge_eco_ID3 = 1100 if isic3H == "K"
replace merge_eco_ID3 = 1200 if isic3H == "L"
replace merge_eco_ID3 = 1300 if isic3H == "M"
replace merge_eco_ID3 = 1400 if isic3H == "N"
replace merge_eco_ID3 = 1500 if isic3H == "O"
replace merge_eco_ID3 = 1600 if isic3H == "P"
replace merge_eco_ID3 = 1700 if isic3H == "Q"
replace merge_eco_ID3 = 1800 if isic3H == "R"
replace merge_eco_ID3 = 1900 if isic3H == "S"
replace merge_eco_ID3 = merge_eco_ID3 + exposure2
drop _merge
sort merge_eco_ID3
merge merge_eco_ID3 using "\...\1b  COP economic density isic3.dta"
generate merge_eco_ID4 = 0 if isic4H == "6666"
replace merge_eco_ID4 = 100 if isic4H == "A"
replace merge_eco_ID4 = 200 if isic4H == "B"
replace merge_eco_ID4 = 300 if isic4H == "C"
replace merge_eco_ID4 = 400 if isic4H == "D"
replace merge_eco_ID4 = 500 if isic4H == "E"
replace merge_eco_ID4 = 600 if isic4H == "F"
replace merge_eco_ID4 = 700 if isic4H == "G"
replace merge_eco_ID4 = 800 if isic4H == "H"
replace merge_eco_ID4 = 900 if isic4H == "I"
replace merge_eco_ID4 = 1000 if isic4H == "J"
replace merge_eco_ID4 = 1100 if isic4H == "K"
replace merge_eco_ID4 = 1200 if isic4H == "L"
replace merge_eco_ID4 = 1300 if isic4H == "M"
replace merge_eco_ID4 = 1400 if isic4H == "N"
replace merge_eco_ID4 = 1500 if isic4H == "O"
replace merge_eco_ID4 = 1600 if isic4H == "P"
replace merge_eco_ID4 = 1700 if isic4H == "Q"
replace merge_eco_ID4 = 1800 if isic4H == "R"
replace merge_eco_ID4 = 1900 if isic4H == "S"
replace merge_eco_ID4 = merge_eco_ID4 + exposure2
drop _merge
sort merge_eco_ID4
merge merge_eco_ID4 using "\...\1b  COP economic density isic4.dta"

* merge social density
generate merge_soc_ID1 = ss1H*10
replace merge_soc_ID1 = merge_soc_ID1 + exposure2
drop _merge
sort merge_soc_ID1
merge merge_soc_ID1 using "\...\1c  COP social density ss1.dta"
generate merge_soc_ID2 = ss2H*10
replace merge_soc_ID2 = merge_soc_ID2 + exposure2
drop _merge
sort merge_soc_ID2
merge merge_soc_ID2 using "\...\1c  COP social density ss2.dta"
generate merge_soc_ID3 = ss3H*10
replace merge_soc_ID3 = merge_soc_ID3 + exposure2
drop _merge
sort merge_soc_ID3
merge merge_soc_ID3 using "\...\1c  COP social density ss3.dta"
generate merge_soc_ID4 = ss4H*10
replace merge_soc_ID4 = merge_soc_ID4 + exposure2
drop _merge
sort merge_soc_ID4
merge merge_soc_ID4 using "\...\1c  COP social density ss4.dta"

* lag density
gen Density_sector = Density_isic1
replace Density_sector = Density_ss1 if Density_isic1 == .
gen Density_sector_L = Density_isic1_L
replace Density_sector_L = Density_ss1_L if Density_isic1_L == .

* 3) Construct risk set and dependent variable
sort ID exposure
gen event2 = 0
replace event2 = 1 if event == 0
gen exitevent = .
replace exitevent = 0 if event == 1 & event2[_n-1] == 0
replace exitevent = . if event == 1 & event2[_n-1] == 0 & ID ~= ID[_n-1]
replace exitevent = 1 if event2 == 1 & event2[_n-1] == 0
replace exitevent = . if event2 == 1 & event2[_n-1] == 0 & ID ~= ID[_n-1]
sort event
br ID exposure* event* exitevent COP if maxexp == 1
* keep track of number organizations (6654+1 for wrong matches)
egen obs_check = seq(), by(ID)
tab obs_check if obs_check == 1
drop if ID == .
* drop if never participated
br if maxexp == 1 & event == 0
drop if maxexp == 1 & event == 0
tab obs_check if obs_check == 1
* (number to start with: 6634 organization participated at least once)

* group subsequent particpations
sort ID exposure
bysort ID: generate episode = sum(exitevent)
replace episode = episode - 1 if exitevent == 1
drop if exitevent == . & maxexp > 1

* descriptives: Figure 1 of paper (Number of organizations by episodes)
egen Episodes = max(episode), by(ID)
replace Episodes = Episodes+1
tab Episodes if exposure <= 1
histogram Episodes if exposure <= 1, freq  xlabel(1 2 3 4 5, valuelabel) addlabels

* drop organization entering the last COP
drop if maxexp == 1
drop obs_check
egen obs_check = seq(), by(ID)
tab obs_check if obs_check == 1
tab obs_check
* (534 of organizations that only entered in last COP (not at risk for exit): 6100 organizations to analyze)

* check all organizations that are right censored and participate all COPs
tab exposure2 exitevent
bysort ID: generate check = sum(exitevent)
bysort ID: egen check2 = max(check)
tab maxexp if check2 == 0 & exposure2 == 15
* (441 organizations never experience exit)
* (+ 534 (cfr. supra) only enter at last observed COP = 975)
bysort ID: gen obs_n = _n
tab obs_n exitevent
* (19 organizations participated to all COPs
tab exitevent if exposure2 == 15
* (718 organizations experience no exit at last observed COP = censored)
* (+ 534 (cfr. supra) only enter at last observed COP = 1252)

* 4) Prepare explanatory variables
* prepare sector variable
generate dstr_ISIC_code1 = 100 if ISIC_code1 == "A"
replace dstr_ISIC_code1 = 101 if ISIC_code1 == "B"
replace  dstr_ISIC_code1 = 102 if ISIC_code1 == "C"
replace  dstr_ISIC_code1 = 103 if ISIC_code1 == "D"
replace  dstr_ISIC_code1 = 104 if ISIC_code1 == "E"
replace  dstr_ISIC_code1 = 105 if ISIC_code1 == "F"
replace  dstr_ISIC_code1 = 106 if ISIC_code1 == "G"
replace  dstr_ISIC_code1 = 107 if ISIC_code1 == "H"
replace  dstr_ISIC_code1 = 108 if ISIC_code1 == "I"
replace  dstr_ISIC_code1 = 109 if ISIC_code1 == "J"
replace  dstr_ISIC_code1 = 110 if ISIC_code1 == "K"
replace  dstr_ISIC_code1 = 111 if ISIC_code1 == "L"
replace  dstr_ISIC_code1 = 112 if ISIC_code1 == "M"
replace  dstr_ISIC_code1 = 113 if ISIC_code1 == "N"
replace  dstr_ISIC_code1 = 114 if ISIC_code1 == "O"
replace  dstr_ISIC_code1 = 115 if ISIC_code1 == "P"
replace  dstr_ISIC_code1 = 116 if ISIC_code1 == "Q"
replace  dstr_ISIC_code1 = 117 if ISIC_code1 == "R"
replace  dstr_ISIC_code1 = 118 if ISIC_code1 == "S"
generate AREA = dstr_ISIC_code1 if BUSINESS == 1 | LABOR == 1
replace AREA = SS_code1 if NGO == 1
replace AREA = dstr_ISIC_code1 if RESEARCH == 1 & dstr_ISIC_code1 != .
replace AREA = SS_code1 if RESEARCH == 1 & SS_code1 != .

* prepare group type dummy variables
gen BUS_SPEC = 0
replace BUS_SPEC = 1 if os4 == 1 & SCOPE == 1
gen BUS_ASS = 0
replace BUS_ASS = 1 if os4 == 1 & SCOPE == 0
gen check3 = RESEARCH + NGO + LABOR + BUS_SPEC + BUS_ASS
tab os4 check3, missing

* prepare control variables density, distance, population and GDP
replace Density_sector = Density_sector + 1
gen logDensity = log(Density_sector)
replace Density_sector_L = Density_sector_L + 1
gen logDensity_L = log(Density_sector_L)
replace Distance = Distance + 1
gen logDistance = log(Distance)
gen logPopulation = log(Population)
gen logGDP = log(GDPCap)

* prepare global and domestic salience
capture drop _merge
sort COP
merge COP using "\...\2 COP global salience.dta"
gen COP_2 = COP
replace COP_2 = "6" if COP == "6a"
replace COP_2 = "6" if COP == "6b"
destring COP_2, gen(COP_3)
gen Country_code2 = Country_code*100 if COP_3 < 10
replace Country_code2 = Country_code*10 if COP_3 >= 10
gen Country_code3 = string(Country_code2)
gen Country_COP = Country_code3+COP
capture drop _merge
sort Country_COP
merge Country_COP using "\...\2 COP domestic media attention.dta"
gen logSalience = log(global_salience)
gen logdomestic_media = log(domestic_media)

* prepare polity (categorical)
destring Polity, replace force
recode Polity (min/4 = 0) (5/8 = 1) (9/10 = 2), gen(Polity_cat)

* prepare organizational level
tab rlm1
replace rlm1 = . if rlm1 == 6666
replace rlm1 = 1 if rlm1 == 2

* prepare country variable for global organizations
replace HEADQ = 1501 if rlm5 == 2 & rlm1 == 3
replace HEADQ = 1502 if rlm5 == 9 & rlm1 == 3
replace HEADQ = 1503 if rlm5 == 21 & rlm1 == 3
replace HEADQ = 1504 if rlm5 == 142 & rlm1 == 3
replace HEADQ = 1505 if rlm5 == 150 & rlm1 == 3
replace HEADQ = 1506 if rlm5 == 419 & rlm1 == 3
replace HEADQ = 1507 if rlm5 == 500 & rlm1 == 3
replace HEADQ = 1508 if rlm5 == 600 & rlm1 == 3
replace HEADQ = 1509 if rlm5 == 700 & rlm1 == 3
replace HEADQ = 1510 if rlm5 == 800 & rlm1 == 3
replace HEADQ = 1511 if rlm5 == 900 & rlm1 == 3
replace HEADQ = 1512 if rlm5 == 999 & rlm1 == 3
replace HEADQ = . if rlm5 == . & rlm1 == 3
replace HEADQ = 1600 if rlm1 == 4

* delete all redundant merged observations
drop if ID == .

* 5) The baseline hazard function: the implementation of splines
* descriptive: risk of exit by number of consecutive participations
sort ID exposure2
bysort ID episode: gen time = _n
table time, content (mean exitevent)

* to compute splines: install the Stata -bspline- package
* => "ssc install bspline"
xtset ID
frencurv, xvar(time) refpts(1 2 5 13 15) gen(splineLIN1_) omit(1)
des splineLIN1_*
xtlogit exitevent splineLIN1_*, or
estat ic
estimates store LIN1
predict PRED_SPLINELIN1
graph twoway line PRED_SPLINELIN1 time, sort
frencurv, xvar(time) refpts(1 2 13 15) gen(splineLIN2_) omit(1)
des splineLIN2_*
xtlogit exitevent splineLIN2_*, or
estat ic
estimates store LIN2
predict PRED_SPLINELIN2
graph twoway line PRED_SPLINELIN2 time, sort
frencurv, xvar(time) refpts(1 2 5 15) gen(splineLIN3_) omit(1)
des splineLIN3_*
xtlogit exitevent splineLIN3_*, or
estat ic
estimates store LIN3
predict PRED_SPLINELIN3
graph twoway line PRED_SPLINELIN3 time, sort 
frencurv, xvar(time) refpts(1 2 5) gen(splineLIN4_) omit(1)
des splineLIN4_*
xtlogit exitevent splineLIN4_*, or
estat ic
estimates store LIN4
predict PRED_SPLINELIN4
graph twoway line PRED_SPLINELIN4 time, sort
frencurv, xvar(time) refpts(2 5 15) gen(splineLIN5_) omit(2)
des splineLIN5_*
xtlogit exitevent splineLIN5_*, or
estat ic
estimates store LIN5
predict PRED_SPLINELIN5
graph twoway line PRED_SPLINELIN5 time, sort
frencurv, xvar(time) refpts(1 2 3 5 15) gen(splineLIN6_)  omit(1)
des splineLIN6_*
xtlogit exitevent splineLIN6_*, or
estat ic
estimates store LIN6
predict PRED_SPLINELIN6
graph twoway line PRED_SPLINELIN6 time, sort
frencurv, xvar(time) refpts(1 2 5 15) gen(splineLIN7_)
des splineLIN7_*
xtlogit exitevent splineLIN7_*, or
estat ic
estimates store LIN7
predict PRED_SPLINELIN7
graph twoway line PRED_SPLINELIN7 time, sort 
frencurv, xvar(time) refpts(1 2 5 7 15) gen(splineLIN8_)
des splineLIN8_*
xtlogit exitevent splineLIN8_*, or
estat ic
estimates store LIN8
predict PRED_SPLINELIN8
graph twoway line PRED_SPLINELIN8 time, sort
* splinelin7 performs best in terms of graphical representation and model fit

* 6) Analysis

* 6.1) Global organizations (Table 2 of paper, Model 1)
preserve
log using "xtmelogit models results (paper).smcl", replace
* drop missings
keep if rlm1 > 1
drop if rlm1 == .
drop if logSalience == .
drop if logDistance == .
drop if ALIGNMENT == .
drop if logDensity_L == .
drop if check3 == 0
drop if AREA == .
drop if HEADQ == .
xi: xtmelogit exitevent /*
*/ splineLIN7_1 splineLIN7_3 splineLIN7_4 /*
*/ logDensity_L /*
*/ BUS_ASS NGO LABOR RESEARCH /*
*/ ALIGNMENT logDistance /*
*/ i.rlm1 /*
*/ logSalience /*
*/ || AREA: || HEADQ: || ID: , or var
estat ic
*predict fit
log off
restore

* 6.2) National-all organizations (Table 2 of paper, Model 2)
preserve
log on
* drop missings
keep if rlm1 == 1
drop if logDistance == .
drop if ALIGNMENT == .
drop if logGDP == .
drop if logDensity_L == .
drop if Polity_cat == .
drop if check3 == 0
drop if AREA == .
drop if HEADQ == .
char Polity_cat[omit] 2
xi: xtmelogit exitevent /*
*/ splineLIN7_1 splineLIN7_3 splineLIN7_4 /*
*/ logDensity_L /*
*/ BUS_ASS NGO LABOR RESEARCH /*
*/ logGDP /*
*/ ALIGNMENT logDistance /*
*/ i.Polity_cat /*
*/ || AREA: || HEADQ: || ID: , or var
estat ic
*predict fit
log off
restore

* 6.3) National-OECD (Table 2 of paper, Model 3)
preserve
log on
* drop missings
keep if rlm1 == 1
drop if logDistance == .
drop if ALIGNMENT == .
drop if logDensity_L == .
drop if logdomestic_media == .
drop if check3 == 0
drop if AREA == .
drop if HEADQ == .
char Polity_cat[omit] 2
xi: xtmelogit exitevent /*
*/ splineLIN7_1 splineLIN7_3 splineLIN7_4 /*
*/ logDensity_L /*
*/ BUS_ASS NGO LABOR RESEARCH /*
*/ ALIGNMENT logDistance /*
*/ logdomestic_media /*
*/ || AREA: || HEADQ: || ID: , or var
estat ic
*predict fit
log off
restore
log close

* 7) Sensitivity analysis
* 7.1) Global organizations (Table A4 of paper, Model 1)
preserve
log using "xtmelogit models sensitivity (appendix).smcl", replace
* drop missings
keep if rlm1 > 1
drop if rlm1 == .
drop if logSalience == .
drop if logDistance == .
drop if ALIGNMENT == .
drop if Density_L_z == .
drop if check3 == 0
drop if AREA == .
drop if HEADQ == .
xi: xtmelogit exitevent /*
*/ splineLIN7_1 splineLIN7_3 splineLIN7_4 /*
*/ Density_L_z /*
*/ BUS_ASS NGO LABOR RESEARCH /*
*/ ALIGNMENT logDistance /*
*/ i.rlm1 /*
*/ logSalience /*
*/ || AREA: || HEADQ: || ID: , or var
estat ic
*predict fit
log off
restore

* 7.2) National-all organizations (Table A4 of paper, Model 2)
preserve
log on
* drop missings
keep if rlm1 == 1
drop if logDistance == .
drop if ALIGNMENT == .
drop if logGDP == .
drop if logDensity_L == .
drop if Polity_cat == .
drop if check3 == 0
drop if AREA == .
drop if HEADQ == .
char Polity_cat[omit] 2
xi: xtmelogit exitevent /*
*/ splineLIN7_1 splineLIN7_3 splineLIN7_4 /*
*/ Density_L_z /*
*/ BUS_ASS NGO LABOR RESEARCH /*
*/ logGDP /*
*/ ALIGNMENT logDistance /*
*/ i.Polity_cat /*
*/ || AREA: || HEADQ: || ID: , or var
estat ic
*predict fit
log off
restore

* 7.3) National-OECD (Table A4 of paper, Model 3)
preserve
log on
* drop missings
keep if rlm1 == 1
drop if logDistance == .
drop if ALIGNMENT == .
drop if logDensity_L == .
drop if logdomestic_media == .
drop if check3 == 0
drop if AREA == .
drop if HEADQ == .
char Polity_cat[omit] 2
xi: xtmelogit exitevent /*
*/ splineLIN7_1 splineLIN7_3 splineLIN7_4 /*
*/ Density_L_z /*
*/ BUS_ASS NGO LABOR RESEARCH /*
*/ ALIGNMENT logDistance /*
*/ logdomestic_media /*
*/ || AREA: || HEADQ: || ID: , or var
estat ic
*predict fit
log off
restore
log close
